package juc_13_stream;

import bean.User;

import java.util.Arrays;
import java.util.List;

public class Demo01 {

    public static void main(String[] args) {
        User u1 = new User(1, "alex", 18);
        User u2 = new User(2, "lucy", 16);
        User u3 = new User(3, "tom", 13);
        User u4 = new User(4, "jack", 16);
        User u5 = new User(5, "jerry", 11);
        User u6 = new User(6, "david", 22);

        List<User> list = Arrays.asList(u1, u2, u3, u4, u5, u6);

        list.stream()
                .filter(u -> u.getId() % 2 == 0)
                .filter(u->{
                    return u.getAge()> 15;
                })
                .map(u->{
                    // u.setName(u.getName().toUpperCase());
                    // return u;
                    return u.getName().toUpperCase();
                })
                .sorted((s1, s2)->{
                    return s1.compareTo(s2);
                })
                .limit(2)
                .forEach(System.out::println);

    }
}
